<template>
  	<div>
	  	<flexbox-item>
	    	<yd-cell-group>
	    	<template v-for="item in arr">
	            <yd-cell-item arrow @click.native="profitinfo(item)">
	                <span class="h3" slot="left">{{item.total_price}}<br> <span class="h4" style="color:#999;">{{item.hexiao_time}}</span></span>
	                <span slot="right">{{item.title}}</span>
	            </yd-cell-item>
	        </template>
	        </yd-cell-group>
	    </flexbox-item>
  	</div>
</template>

<script>

import { mapGetters, mapActions } from 'vuex'


export default {
	name: 'profitlist',
	data () {
		return {

		}
	},

	computed: {
		...mapGetters([
		    'income',
		    'preincome',
		    'company_code',
		    'userdata',
		]),

		arr () {

			if(this.what === 'income'){
				console.log('111111');
				console.log(this.income.results);
				return this.income.results;
			}else if(this.what === 'preincome'){
				console.log('2222');
				console.log(this.preincome.results);
				return this.preincome.results;
			}else{
				return [];
			}
		},

		what () {
			return this.$route.params.what;
		}

	},

	methods: {
		profitinfo (item) {

			item['type'] = this.$route.params.what;
			item['company_code'] = this.company_code;

			this.$router.push({ 
				name: 'profitinfo', 
				query : item,
			})
		}

	},

	created () {
		console.log(this.what);
		if(this.what === 'income'){
			this.$store.dispatch('getIncome', {
				'level_code' : this.userdata.level,
			});
		}else if(this.what === 'preincome'){
			this.$store.dispatch('getPreincome', {
				'level_code' : this.userdata.level,
			});
		}else{
			console.log('错误');
		}
	},

	components : {
	}


}
</script>

<style scoped>

.more {
	width: 100%;
	height: 50px;
	line-height: 50px;
	float: left;
	text-align: center;
}

</style>
